package com.pacyki.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;

import com.pacyki.gcards.R;

public class ImagesAdapter extends BaseAdapter{
	
	private Context mContext;
	private String[] mItems;
	
	public ImagesAdapter(Context context, String[] items) {
		mContext = context;
		mItems = items;
	}
	
	@Override
	public int getCount() {
		return mItems.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		ImageButtonHolder holder;
		final ImageButton imageButton;
		if (null == row){
			LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			row = inflater.inflate(R.layout.image_category_cell, null, false);
			holder = new ImageButtonHolder(row);
			row.setTag(holder);
			imageButton = holder.getImageButton();
			imageButton.setImageResource(R.drawable.hearts_green);
		} else{
			holder = (ImageButtonHolder) row.getTag();
			imageButton = holder.getImageButton();
			imageButton.setImageResource(R.drawable.red);
		}
		imageButton.setImageResource(R.drawable.rabbit);
		imageButton.setOnClickListener((OnClickListener) mContext);
		return row;
	}
	
}
